package com.ss.android.lockscreen.c.b;

import android.content.Context;

import com.ss.android.lockscreen.bb;

import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.Timer;
import java.util.TimerTask;

import inline.TextDemo;

public final class a {
    private static Context a;
    private static c b;
    private static Timer c;
    private static TimerTask d;
    private static ArrayList e;

    static {
        c = new Timer();
        d = new com.ss.android.lockscreen.c.b.b();
        e = new ArrayList();
    }

    public static c a() {
        return b;
    }

    public static void a(Context arg6, String arg7) {
        if (arg6 == null) {
            throw new RuntimeException("context is null");
        }

        if (a == null) {
            a = arg6;
            b = new c(arg6, arg7);
            c.schedule(d, 0, 14400000);
        }
    }

    public static void a(a$a arg4) {
        int v0_1;
        ArrayList v2 = e;
        synchronized (v2) {
            Iterator v3 = e.iterator();
            do {
                if (v3.hasNext()) {
                    if (v3.next() != arg4) {
                        continue;
                    }
                    v0_1 = 1;
                    break;
                } else {
                    v0_1 = 0;
                    break;
                }
            }
            while (true);

            if (v0_1 == 0) {
                e.add(arg4);
            }

        }
    }

    static void b() {
        ArrayList v1_2;
        Context v0 = a;
        StringBuilder v1 = new StringBuilder("http://open.snssdk.com/data/stream/tt_sl/app_setting/v1/?");
        android.support.design.a.a(v1, v0);
        String v0_1 = v1.toString();
        if (bb.a().d != null) {
            v0_1 = com.ss.android.lockscreen.e.e$c.a(v0_1);
            if (TextDemo.c(v0_1)) {
                return;
            }

            try {
                JSONObject v1_1 = new JSONObject(v0_1);
                c v0_3 = b;
                v1_1 = v1_1.optJSONObject("lockscreen_setting");
                if (v1_1 != null) {
                    v0_3.a.a("is_lockscreen_enable", v1_1.optBoolean("is_lockscreen_enable", false));
                }

                v1_2 = e;
                synchronized (v1_2) {
                    Iterator v2 = e.iterator();
                    while (v2.hasNext()) {
                        ((a$a) v2.next()).a.b();
                    }
                }
            } catch (JSONException v0_2) {
                v0_2.printStackTrace();
            }
        }
    }

    public static final class a$a {
        public final bb a;

        public a$a(bb arg1) {
            this.a = arg1;
        }
    }
}

